package API.Collection.List.ArrayList.Basis.test;

import java.util.ArrayList;

class Student {
    private String name;
    private int age;

    public Student() {
    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String toString() {
        return "STUDENT{name = " + name + ", age = " + age + "}";
    }
}

public class Traverse {
    public static void main(String[] args) {
        Student stu1 = new Student("Nick", 18);
        Student stu2 = new Student("Jack", 22);
        Student stu3 = new Student("Alic", 21);
        ArrayList<Student> list = new ArrayList<>();
        list.add(stu1);
        list.add(stu2);
        list.add(stu3);
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i).toString());
        }
    }
}
